<include src="../templates/html-header.html" path=".."></include>
<body>
  <div
    v-cloak
    ref="auiWrapper"
    class="aui-wrapper"
    :class="[
      'aui-header--' + headerSkin,
      'aui-aside--' + asideSkin,
      {
        'aui-wrapper--center': wrapperCenter,
        'aui-header--fixed': headerFixed,
        'aui-aside--fixed': asideFixed,
        'aui-aside--fold': asideFold,
        'aui-aside--top': asideTop,
        'aui-control--fixed': controlFixed,
        'aui-control--open': controlOpen,
        'aui-main-tabs__header--fixed': mainTabsHeaderFixed
      }
    ]"
    v-loading.fullscreen.lock="loading"
    element-loading-text="拼命加载中">
    <template v-if="!loading">
      <!-- aui-header -->
      <include src="../templates/layout-header.html" path=".."></include>
      <!-- aui-aside -->
      <include src="../templates/layout-aside.html" path=".."></include>
      <!-- aui-control -->
      <include src="../templates/layout-control.html" path=".."></include>
      <!-- aui-main -->
      <main class="aui-main">
        <!-- standard 标准 -->
        <div v-show="mainType === 'standard'" class="aui-main__hd">
          <el-breadcrumb separator="/">
            <el-breadcrumb-item>renren-aui</el-breadcrumb-item>
            <el-breadcrumb-item>图表</el-breadcrumb-item>
            <el-breadcrumb-item>Echarts</el-breadcrumb-item>
          </el-breadcrumb>
        </div>
        <div v-show="mainType === 'standard'" class="aui-main__bd">
          <include src="../templates/pages/echarts.html" path=".."></include>
        </div>
        <!-- tabs 标签页 -->
        <el-dropdown v-show="mainType === 'tabs'" class="aui-main-tabs__tool">
          <i class="el-icon-arrow-down"></i>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>关闭当前标签页</el-dropdown-item>
            <el-dropdown-item>关闭其它标签页</el-dropdown-item>
            <el-dropdown-item>关闭全部标签页</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
        <el-tabs v-show="mainType === 'tabs'" class="aui-main-tabs aui-tabs" v-model="mainTabsActive">
          <el-tab-pane label="home" name="home" :closable="false" class="aui-main-tabs__pane--full">
            <svg slot="label" class="aui-content--tabs-icon-nav icon-svg" aria-hidden="true"><use xlink:href="#icon-home"></use></svg>
            <include src="../templates/pages/index.html" path=".."></include>
          </el-tab-pane>
          <el-tab-pane label="Echarts" name="Echarts" :closable="false">
            <include src="../templates/pages/echarts.html" path=".."></include>
          </el-tab-pane>
          <el-tab-pane label="标签页3" name="3" closable>标签页3</el-tab-pane>
          <el-tab-pane label="标签页5" name="5" closable>
            <span slot="label"><i class="el-icon-date"></i> 标签页5</span>
          </el-tab-pane>
          <el-tab-pane label="标签页6" name="6" closable>标签页6</el-tab-pane>
          <el-tab-pane label="标签页7" name="7" closable>标签页7</el-tab-pane>
          <el-tab-pane label="标签页8" name="8" closable>标签页8</el-tab-pane>
          <el-tab-pane label="标签页9" name="9" closable>标签页9</el-tab-pane>
          <el-tab-pane label="标签页10" name="10" closable>标签页10</el-tab-pane>
        </el-tabs>
      </main>
      <!-- aui-footer -->
      <include src="../templates/layout-footer.html" path=".."></include>
    </template>
  </div>
  <include src="../templates/html-scripts.html" path=".."></include>
  <script src="../plugins/echarts-3.8.5/echarts.min.js"></script>
  <script>
    (function () {
      var vm = window.vm = new Vue({
        el: '.aui-wrapper',
        data: function () {
          return {
            // 滚动条, 滚动高度
            scrollbarHeight: 0,
            // DOM Element对象
            DOM: {},
            // 加载中
            loading: true,
            // 容器, 居中
            wrapperCenter: false,
            // 头部, 皮肤 (white 白色 / colorful 鲜艳)
            headerSkin: 'colorful',
            // 头部, 固定状态
            headerFixed: false,
            // 侧边, 皮肤 (white 白色 / dark 黑色)
            asideSkin: 'dark',
            // 侧边, 固定状态
            asideFixed: false,
            // 侧边, 折叠状态
            asideFold: false,
            // 侧边, 至头部状态
            asideTop: false,
            // 侧边, 菜单显示状态 (控制台“至头部”操作时, el-menu组件需根据mode属性重新渲染)
            asideMenuVisible: true,
            // 侧边, 菜单选中
            asideMenuActive: 'chart-echarts',
            // 搜索, 显示状态
            searchVisible: false,
            // 搜索, 值
            search: '',
            // 控制台, 固定状态
            controlFixed: false,
            // 控制台, 打开状态
            controlOpen: false,
            // 控制台, 标签页选中
            controlTabsActive: 'layout',
            // 主内容, 展示类型 (standard 标准 / tabs 标签页)
            mainType: 'standard', 
            // 主标签页, 列表
            mainTabs: [],
            // 主标签页, 选中
            mainTabsActive: 'chart-echarts',
            // 主标签页, 头部固定状态
            mainTabsHeaderFixed: false,
            // 皮肤, 默认值
            skin: 'orange',
            // 皮肤, 列表
            skinList: [
              { name: 'blue'     , color: '#3E8EF7', remark: '蓝色' },
              { name: 'brown'    , color: '#997B71', remark: '棕色' },
              { name: 'cyan'     , color: '#0BB2D4', remark: '青色' },
              { name: 'gray'     , color: '#757575', remark: '灰色' },
              { name: 'green'    , color: '#11C26D', remark: '绿色' },
              { name: 'indigo'   , color: '#667AFA', remark: '靛青色' },
              { name: 'orange'   , color: '#EB6709', remark: '橙色' },
              { name: 'pink'     , color: '#F74584', remark: '粉红色' },
              { name: 'purple'   , color: '#9463F7', remark: '紫色' },
              { name: 'red'      , color: '#FF4C52', remark: '红色' },
              { name: 'turquoise', color: '#17B3A3', remark: '蓝绿色' },
              { name: 'yellow'   , color: '#FCB900', remark: '黄色' }
            ],
            indexNoticeTabsActive: '1',
            indexPersonalTabsActive: '1',
            chartLine: null,
            chartBar: null,
            chartPie: null,
            chartScatter: null
          }
        },
        watch: {
          scrollbarHeight: function (val) {
            vm.yLayoutFixedHandle();
          },
          wrapperCenter: function (val) {
            vm.headerFixed = false;
            vm.asideFixed = false;
            vm.controlFixed = false;
            vm.mainTabsHeaderFixed = false;
          },
          headerFixed: function (val) {
            vm.yLayoutFixedHandle();
          },
          asideFixed: function (val) {
            vm.yLayoutFixedHandle();
          },
          asideTop: function (val) {
            vm.yLayoutFixedHandle();
            vm.asideMenuVisible = false;
            vm.$nextTick(function () {
              vm.asideMenuVisible = true;
            });
          },
          controlFixed: function (val) {
            vm.yLayoutFixedHandle();
          },
          mainTabsHeaderFixed: function (val) {
            vm.yLayoutFixedHandle();
          }
        },
        beforeCreate () {
          vm = this;
        },
        created () {
          vm.loading = false;
          vm.$nextTick(function () {
            vm.scrollbarHandle(true);
            vm.getDOM();
            vm.searchHandle();
            vm.initChartLine();
            vm.initChartBar();
            vm.initChartPie();
            vm.initChartScatter();
          });
        },
        methods: {
          // 滚动条, 滚动距离
          scrollbarHandle: function (isInit) {
            if (isInit && typeof(isInit) === 'boolean') {
              window.addEventListener('scroll', vm.scrollbarHandle);
            }
            vm.scrollbarHeight = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
          },
          // 获取DOM Element对象
          getDOM: function () {
            vm.DOM.header  = vm.$refs.auiWrapper.querySelector('.aui-header');
            vm.DOM.aside   = vm.$refs.auiWrapper.querySelector('.aui-aside');
            vm.DOM.control = vm.$refs.auiWrapper.querySelector('.aui-control');
            vm.DOM.main    = vm.$refs.auiWrapper.querySelector('.aui-main');
            vm.DOM.mainTabsTool   = vm.DOM.main.querySelector('.aui-main-tabs__tool');
            vm.DOM.mainTabsHeader = vm.DOM.main.querySelector('.aui-main-tabs > .el-tabs__header');
          },
          // Y轴布局固定
          yLayoutFixedHandle: function () {
            var _offsetHeight = vm.scrollbarHeight >= vm.DOM.header.offsetHeight ? 0 : vm.DOM.header.offsetHeight - vm.scrollbarHeight;
            // 侧边
            if (!vm.headerFixed && vm.asideTop && vm.asideFixed) {
              vm.DOM.aside.style.top = _offsetHeight + 'px';
            } else {
              vm.DOM.aside.style.removeProperty('top');
            }
            // 控制台
            if (!vm.headerFixed && vm.controlFixed) {
              vm.DOM.control.style.top = _offsetHeight + 'px';
            } else {
              vm.DOM.control.style.removeProperty('top');
            }
            // 主标签页, 头部
            if (!vm.headerFixed && vm.mainTabsHeaderFixed) {
              if (vm.asideTop && vm.asideFixed) {
                _offsetHeight += vm.DOM.aside.offsetHeight;
              }
              if (vm.asideTop && !vm.asideFixed) {
                _offsetHeight = vm.scrollbarHeight >= vm.DOM.header.offsetHeight + vm.DOM.aside.offsetHeight ? 0 : vm.DOM.header.offsetHeight + vm.DOM.aside.offsetHeight - vm.scrollbarHeight;
              }
              vm.DOM.mainTabsTool.style.top = _offsetHeight + 'px';
              vm.DOM.mainTabsHeader.style.top = _offsetHeight + 'px';
            } else {
              vm.DOM.mainTabsTool.style.removeProperty('top');
              vm.DOM.mainTabsHeader.style.removeProperty('top');
            }
          },
          // 搜索, 显示／隐藏
          searchHandle: function () {
            vm.$refs.auiWrapper.querySelector('.aui-search__toggle').addEventListener('click', function (e) {
              e.cancelBubble = true;
            });
            vm.$refs.auiWrapper.querySelector('.aui-search').addEventListener('click', function (e) {
              e.cancelBubble = true;
            });
            window.addEventListener('click', function (e) {
              if (vm.searchVisible) {
                vm.searchVisible = false;
              }
            });
          },
          // 跳转页面
          gotoPageHandle: function (url) {
            if (!/\S/.test(url) || location.href.indexOf(url.replace(/^(\.*\/)*/, '')) !== -1) {
              return false;
            }
            window.location.href = url;
          },
          // 皮肤切换
          skinChangeHandle: function (val) {
            var styleList = [
              {
                id: 'J_elementTheme',
                url: '../element-theme/' + val + '/index.css?t=' + new Date().getTime()
              },
              {
                id: 'J_auiSKin',
                url: '../css/aui-' + val + '.min.css?t=' + new Date().getTime()
              }
            ];
            for (var i = 0; i < styleList.length; i++) {
              var el = document.querySelector('#' + styleList[i].id);
              if (el) {
                el.href = styleList[i].url;
                continue;
              }
              el = document.createElement('link');
              el.id = styleList[i].id;
              el.href = styleList[i].url;
              el.rel = 'stylesheet';
              document.querySelector('head').appendChild(el);
            }
          },
          // 折线图
          initChartLine: function () {
            var option = {
              'title': {
                'text': '折线图堆叠'
              },
              'tooltip': {
                'trigger': 'axis'
              },
              'legend': {
                'data': [ '邮件营销', '联盟广告', '视频广告', '直接访问', '搜索引擎' ]
              },
              'grid': {
                'left': '3%',
                'right': '4%',
                'bottom': '3%',
                'containLabel': true
              },
              'toolbox': {
                'feature': {
                  'saveAsImage': { }
                }
              },
              'xAxis': {
                'type': 'category',
                'boundaryGap': false,
                'data': [ '周一', '周二', '周三', '周四', '周五', '周六', '周日' ]
              },
              'yAxis': {
                'type': 'value'
              },
              'series': [
                {
                  'name': '邮件营销',
                  'type': 'line',
                  'stack': '总量',
                  'data': [ 120, 132, 101, 134, 90, 230, 210 ]
                },
                {
                  'name': '联盟广告',
                  'type': 'line',
                  'stack': '总量',
                  'data': [ 220, 182, 191, 234, 290, 330, 310 ]
                },
                {
                  'name': '视频广告',
                  'type': 'line',
                  'stack': '总量',
                  'data': [ 150, 232, 201, 154, 190, 330, 410 ]
                },
                {
                  'name': '直接访问',
                  'type': 'line',
                  'stack': '总量',
                  'data': [ 320, 332, 301, 334, 390, 330, 320 ]
                },
                {
                  'name': '搜索引擎',
                  'type': 'line',
                  'stack': '总量',
                  'data': [ 820, 932, 901, 934, 1290, 1330, 1320 ]
                }
              ]
            };
            vm.chartLine = echarts.init(vm.$refs.auiWrapper.querySelectorAll('.chart-box')[0]);
            vm.chartLine.setOption(option);
            window.addEventListener('resize', function () {
              vm.chartLine.resize();
            });
          },
          // 柱状图
          initChartBar: function () {
            var option = {
              tooltip: {
                trigger: 'axis',
                axisPointer: {
                  type: 'shadow'
                }
              },
              legend: {
                data: ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎', '百度', '谷歌', '必应', '其他']
              },
              grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
              },
              xAxis: [
                {
                  type: 'category',
                  data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
                }
              ],
              yAxis: [
                {
                  type: 'value'
                }
              ],
              series: [
                {
                  name: '直接访问',
                  type: 'bar',
                  data: [320, 332, 301, 334, 390, 330, 320]
                },
                {
                  name: '邮件营销',
                  type: 'bar',
                  stack: '广告',
                  data: [120, 132, 101, 134, 90, 230, 210]
                },
                {
                  name: '联盟广告',
                  type: 'bar',
                  stack: '广告',
                  data: [220, 182, 191, 234, 290, 330, 310]
                },
                {
                  name: '视频广告',
                  type: 'bar',
                  stack: '广告',
                  data: [150, 232, 201, 154, 190, 330, 410]
                },
                {
                  name: '搜索引擎',
                  type: 'bar',
                  data: [862, 1018, 964, 1026, 1679, 1600, 1570],
                  markLine: {
                    lineStyle: {
                      normal: {
                        type: 'dashed'
                      }
                    },
                    data: [
                      [{ type: 'min' }, { type: 'max' }]
                    ]
                  }
                },
                {
                  name: '百度',
                  type: 'bar',
                  barWidth: 5,
                  stack: '搜索引擎',
                  data: [620, 732, 701, 734, 1090, 1130, 1120]
                },
                {
                  name: '谷歌',
                  type: 'bar',
                  stack: '搜索引擎',
                  data: [120, 132, 101, 134, 290, 230, 220]
                },
                {
                  name: '必应',
                  type: 'bar',
                  stack: '搜索引擎',
                  data: [60, 72, 71, 74, 190, 130, 110]
                },
                {
                  name: '其他',
                  type: 'bar',
                  stack: '搜索引擎',
                  data: [62, 82, 91, 84, 109, 110, 120]
                }
              ]
            }
            vm.chartBar = echarts.init(vm.$refs.auiWrapper.querySelectorAll('.chart-box')[1]);
            vm.chartBar.setOption(option);
            window.addEventListener('resize', function () {
              vm.chartBar.resize()
            })
          },
          // 饼状图
          initChartPie: function () {
            var option = {
              backgroundColor: '#2c343c',
              title: {
                text: 'Customized Pie',
                left: 'center',
                top: 20,
                textStyle: {
                  color: '#ccc'
                }
              },
              tooltip: {
                trigger: 'item',
                formatter: '{a} <br/>{b} : {c} ({d}%)'
              },
              visualMap: {
                show: false,
                min: 80,
                max: 600,
                inRange: {
                  colorLightness: [0, 1]
                }
              },
              series: [
                {
                  name: '访问来源',
                  type: 'pie',
                  radius: '55%',
                  center: ['50%', '50%'],
                  data: [
                    { value: 335, name: '直接访问' },
                    { value: 310, name: '邮件营销' },
                    { value: 274, name: '联盟广告' },
                    { value: 235, name: '视频广告' },
                    { value: 400, name: '搜索引擎' }
                  ].sort(function (a, b) { return a.value - b.value }),
                  roseType: 'radius',
                  label: {
                    normal: {
                      textStyle: {
                        color: 'rgba(255, 255, 255, 0.3)'
                      }
                    }
                  },
                  labelLine: {
                    normal: {
                      lineStyle: {
                        color: 'rgba(255, 255, 255, 0.3)'
                      },
                      smooth: 0.2,
                      length: 10,
                      length2: 20
                    }
                  },
                  itemStyle: {
                    normal: {
                      color: '#c23531',
                      shadowBlur: 200,
                      shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                  },
                  animationType: 'scale',
                  animationEasing: 'elasticOut',
                  animationDelay: function (idx) {
                    return Math.random() * 200
                  }
                }
              ]
            }
            vm.chartPie = echarts.init(vm.$refs.auiWrapper.querySelectorAll('.chart-box')[2]);
            vm.chartPie.setOption(option);
            window.addEventListener('resize', function () {
              vm.chartPie.resize();
            })
          },
          // 散点图
          initChartScatter: function () {
            var option = {
              backgroundColor: new echarts.graphic.RadialGradient(0.3, 0.3, 0.8, [
                { offset: 0, color: '#f7f8fa' },
                { offset: 1, color: '#cdd0d5' }
              ]),
              title: {
                text: '1990 与 2015 年各国家人均寿命与 GDP'
              },
              legend: {
                right: 10,
                data: ['1990', '2015']
              },
              xAxis: {
                splitLine: {
                  lineStyle: {
                    type: 'dashed'
                  }
                }
              },
              yAxis: {
                splitLine: {
                  lineStyle: {
                    type: 'dashed'
                  }
                },
                scale: true
              },
              series: [
                {
                  name: '1990',
                  data: [
                    [28604, 77, 17096869, 'Australia', 1990],
                    [31163, 77.4, 27662440, 'Canada', 1990],
                    [1516, 68, 1154605773, 'China', 1990],
                    [13670, 74.7, 10582082, 'Cuba', 1990],
                    [28599, 75, 4986705, 'Finland', 1990],
                    [29476, 77.1, 56943299, 'France', 1990],
                    [31476, 75.4, 78958237, 'Germany', 1990],
                    [28666, 78.1, 254830, 'Iceland', 1990],
                    [1777, 57.7, 870601776, 'India', 1990],
                    [29550, 79.1, 122249285, 'Japan', 1990],
                    [2076, 67.9, 20194354, 'North Korea', 1990],
                    [12087, 72, 42972254, 'South Korea', 1990],
                    [24021, 75.4, 3397534, 'New Zealand', 1990],
                    [43296, 76.8, 4240375, 'Norway', 1990],
                    [10088, 70.8, 38195258, 'Poland', 1990],
                    [19349, 69.6, 147568552, 'Russia', 1990],
                    [10670, 67.3, 53994605, 'Turkey', 1990],
                    [26424, 75.7, 57110117, 'United Kingdom', 1990],
                    [37062, 75.4, 252847810, 'United States', 1990]
                  ],
                  type: 'scatter',
                  symbolSize: function (data) {
                    return Math.sqrt(data[2]) / 5e2
                  },
                  label: {
                    emphasis: {
                      show: true,
                      formatter: function (param) {
                        return param.data[3]
                      },
                      position: 'top'
                    }
                  },
                  itemStyle: {
                    normal: {
                      shadowBlur: 10,
                      shadowColor: 'rgba(120, 36, 50, 0.5)',
                      shadowOffsetY: 5,
                      color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [
                        { offset: 0, color: 'rgb(251, 118, 123)' },
                        { offset: 1, color: 'rgb(204, 46, 72)' }
                      ])
                    }
                  }
                },
                {
                  name: '2015',
                  data: [
                    [44056, 81.8, 23968973, 'Australia', 2015],
                    [43294, 81.7, 35939927, 'Canada', 2015],
                    [13334, 76.9, 1376048943, 'China', 2015],
                    [21291, 78.5, 11389562, 'Cuba', 2015],
                    [38923, 80.8, 5503457, 'Finland', 2015],
                    [37599, 81.9, 64395345, 'France', 2015],
                    [44053, 81.1, 80688545, 'Germany', 2015],
                    [42182, 82.8, 329425, 'Iceland', 2015],
                    [5903, 66.8, 1311050527, 'India', 2015],
                    [36162, 83.5, 126573481, 'Japan', 2015],
                    [1390, 71.4, 25155317, 'North Korea', 2015],
                    [34644, 80.7, 50293439, 'South Korea', 2015],
                    [34186, 80.6, 4528526, 'New Zealand', 2015],
                    [64304, 81.6, 5210967, 'Norway', 2015],
                    [24787, 77.3, 38611794, 'Poland', 2015],
                    [23038, 73.13, 143456918, 'Russia', 2015],
                    [19360, 76.5, 78665830, 'Turkey', 2015],
                    [38225, 81.4, 64715810, 'United Kingdom', 2015],
                    [53354, 79.1, 321773631, 'United States', 2015]
                  ],
                  type: 'scatter',
                  symbolSize: function (data) {
                    return Math.sqrt(data[2]) / 5e2
                  },
                  label: {
                    emphasis: {
                      show: true,
                      formatter: function (param) {
                        return param.data[3]
                      },
                      position: 'top'
                    }
                  },
                  itemStyle: {
                    normal: {
                      shadowBlur: 10,
                      shadowColor: 'rgba(25, 100, 150, 0.5)',
                      shadowOffsetY: 5,
                      color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [
                        { offset: 0, color: 'rgb(129, 227, 238)' },
                        { offset: 1, color: 'rgb(25, 183, 207)' }
                      ])
                    }
                  }
                }
              ]
            }
            vm.chartPie = echarts.init(vm.$refs.auiWrapper.querySelectorAll('.chart-box')[3]);
            vm.chartPie.setOption(option);
            window.addEventListener('resize', function () {
              vm.chartPie.resize();
            })
          }
        }
      });
    })();
  </script>
</body>
</html>
